<?php
/*
  [EWEISHOP] Copyright(C) 2017 Elinkint Inc.
  This is NOT a freeware, use is subject to license terms
   
  MiniProgramAnalysis.php 2018-05-25 16:32 cunx $
   
*/

namespace common\library\wechat\miniprogram;

use common\component\wechat\Wechat;
use common\library\wechat\WechatApi;

/**
 * 小程序数据统计与分析
 * Class MiniProgramAnalysis
 * @package common\library\wechat\miniprogram
 * @author cunx
 */
class MiniProgramAnalysis extends WechatApi
{
    static $apiType = 'miniProgram';

    /**
     * 概况趋势
     * @param string $from  开始日期
     * @param string $to    结束日期，限定查询1天数据，允许设置的最大值为开始日期的昨日
     * @return array|bool|void
     * @author cunx
     */
    public static function summaryTrend(string $from, string $to){
        $result = self::getInstance()->data_cube->summaryTrend($from, $to);
        return Wechat::apiError($result);
    }

    /**
     * 访问日趋势
     * @param string $from
     * @param string $to
     * @return array|bool|void
     * @author cunx
     */
    public static function dailyVisitTrend(string $from, string $to){
        $result = self::getInstance()->data_cube->dailyVisitTrend($from, $to);
        return Wechat::apiError($result);
    }

    /**
     * 访问周趋势
     * @param string $from
     * @param string $to
     * @return array|bool|void
     * @author cunx
     */
    public static function weeklyVisitTrend(string $from, string $to){
        $result = self::getInstance()->data_cube->weeklyVisitTrend($from, $to);
        return Wechat::apiError($result);
    }

    /**
     * 访问月趋势
     * @param string $from
     * @param string $to
     * @return array|bool|void
     * @author cunx
     */
    public static function monthlyVisitTrend(string $from, string $to){
        $result = self::getInstance()->data_cube->monthlyVisitTrend($from, $to);
        return Wechat::apiError($result);
    }

    /**
     * 访问分布
     * @param string $from
     * @param string $to
     * @return array|bool|void
     * @author cunx
     */
    public static function visitDistribution(string $from, string $to){
        $result = self::getInstance()->data_cube->visitDistribution($from, $to);
        return Wechat::apiError($result);
    }

    /**
     * 访问日留存
     * @param string $from
     * @param string $to
     * @return array|bool|void
     * @author cunx
     */
    public static function dailyRetainInfo(string $from, string $to){
        $result = self::getInstance()->data_cube->dailyRetainInfo($from, $to);
        return Wechat::apiError($result);
    }

    /**
     * 访问周留存
     * @param string $from
     * @param string $to
     * @return array|bool|void
     * @author cunx
     */
    public static function weeklyRetainInfo(string $from, string $to){
        $result = self::getInstance()->data_cube->weeklyRetainInfo($from, $to);
        return Wechat::apiError($result);
    }

    /**
     * 访问月留存
     * @param string $from
     * @param string $to
     * @return array|bool|void
     * @author cunx
     */
    public static function monthlyRetainInfo(string $from, string $to){
        $result = self::getInstance()->data_cube->monthlyRetainInfo($from, $to);
        return Wechat::apiError($result);
    }

    /**
     * 访问页面
     * @param string $from
     * @param string $to
     * @return array|bool|void
     * @author cunx
     */
    public static function visitPage(string $from, string $to){
        $result = self::getInstance()->data_cube->visitPage($from, $to);
        return Wechat::apiError($result);
    }

    /**
     * 用户画像分布数据
     * @param string $from  Y-m-d格式日期
     * @param string $to    Y-m-d格式日期，结束日期，开始日期与结束日期相差的天数限定为0/6/29，分别表示查询最近1/7/30天数据，允许设置的最大值为昨日
     * @return array|bool|void
     * @author cunx
     */
    public static function userPortrait(string $from, string $to){
        $result = self::getInstance()->data_cube->userPortrait($from, $to);
        return Wechat::apiError($result);
    }
}